package com.timothy.fund.data;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil {
	public static final String DFSTRING = "yyyy/mm/dd";
	
	public static Date parseDate(String date) {
		SimpleDateFormat df = new SimpleDateFormat(DFSTRING);
		Date resultDate = null;
		try {
			resultDate = df.parse(date);
		} catch (ParseException e) {
			
		}
		return resultDate;
	}
	
    public static String getCurrentDate() {
        SimpleDateFormat ft = new SimpleDateFormat(DFSTRING);
        Date dd = new Date();
        return ft.format(dd);
    }
    
    public static long getQuot(String time1, String time2) {
        long quot = 0;
        SimpleDateFormat ft = new SimpleDateFormat(DFSTRING);
        try {
            Date date1 = ft.parse(time1);
            Date date2 = ft.parse(time2);
            quot = date1.getTime() - date2.getTime();
            quot = quot/1000/60/60/24;
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return quot;
    }
    
}
